#!/bin/bash

do_overclock_rockpro64() {
    # disable low cores
    echo "0" > /sys/devices/system/cpu/cpu0/online
    echo "0" > /sys/devices/system/cpu/cpu1/online
    echo "0" > /sys/devices/system/cpu/cpu2/online
    echo "0" > /sys/devices/system/cpu/cpu3/online
}


if test "${1}" = "start"
then
    MODEL=$(cat /sys/firmware/devicetree/base/model)

    case "${MODEL}" in
	"Pine64 RockPro64 v2.1"|"Anbernic RG552")
	    do_overclock_rockpro64
	    ;;
    esac
fi

if test "${1}" = "stop"
then
    # enable low cores - required for reboot
    echo "1" > /sys/devices/system/cpu/cpu0/online
    echo "1" > /sys/devices/system/cpu/cpu1/online
    echo "1" > /sys/devices/system/cpu/cpu2/online
    echo "1" > /sys/devices/system/cpu/cpu3/online
fi
